<div class="tab_item" style="display: block">
    <div class="toolbar clearfix">
        <div class="float_right">
        <@app.has_oper oper_code='1_3_2'>
            <button class="btn btn_green" onclick="add_agency_deduct_money()">新建</button>
        </@app.has_oper>
        </div>
        <h3>扣费项目</h3>
    </div>
    <div class="grid" style="height:345px;">
        <table id="page_table_box_${pid}"></table>
    </div>
</div>


<script>

    (function () {
        $('#page_table_box_${pid}').datagrid({
            fit: true,
            width: '100%',
            height: '100%',
            striped: true,
            pagination: true,
            url: "${contextPath}/security/hdw/agency_deduct_money/page.htm?agencyId=${agencyId}",
            pageSize: 10,
            pageList: [10, 50, 100],
            fitColumns: true,
            idField: 'id',
            singleSelect: true,
            selectOnCheck: false,
            checkOnSelect: false,
            autoRowHeight: false,
            rowStyler: gridRowStyler,
            columns: [
                [
                    { field: 'checkbox', checkbox: true },
                    {
                        title: '扣费项目',
                        align: 'center',
                        field: 'itemName',
                        width: 40
                    },
                    {
                        title: '金额(元)',
                        align: 'center',
                        field: 'money',
                        width: 40,
                        formatter: function(val, row) {
                            return "-" + new Number(val).toFixed(2);
                        }
                    },
                    {
                        title: '备注',
                        align: 'center',
                        field: 'memo',
                        width: 60
                    },
                    {
                        title: '操作',
                        align: 'center',
                        field: 'action',
                        width: 60,
                        formatter: function(val, row) {
                            var html="";
                        <@app.has_oper oper_code='1_3_3'>
                            html += ' <a href="javascript:edit_agency_deduct_money(ID)">修改</a>';
                        </@app.has_oper>
                        <@app.has_oper oper_code='1_3_4'>
                            html += ' <a href="javascript:remove_agency_deduct_money(ID)">删除</a>';
                        </@app.has_oper>
                            return html.replace(/ID/g, row.id);
                        }
                    }
                ]
            ]
        });
    })();

    $('#${pid}').data('ok', function() {
        return true;
    });

    function reload_agency_deduct_money() {
        var datagrid = $('#page_table_box_${pid}');
        datagrid.datagrid('reload');
    }

    function add_agency_deduct_money() {
        App.dialog.show({
            css: 'width:300px;height:230px;overflow:visible;',
            title: '新建',
            href: "${contextPath}/security/hdw/agency_deduct_money/add.htm?agencyId=${agencyId}",
            event: {
                onClose: function() {
                    reload_agency_deduct_money();
                }
            }
        });
    }

    function edit_agency_deduct_money(id) {
        App.dialog.show({
            css: 'width:300px;height:230px;overflow:visible;',
            title: '修改',
            href: "${contextPath}/security/hdw/agency_deduct_money/edit.htm?id=" + id,
            event: {
                onClose: function() {
                    reload_agency_deduct_money();
                }
            }
        });
    }

    function remove_agency_deduct_money(id) {
        $.messager.confirm('提示信息', '确认删除?', function(ok) {
            if(ok) {
                $.post('${contextPath}/security/hdw/agency_deduct_money/delete.htm', {
                    id: id, agencyId: ${agencyId}
                }, function (json) {
                    if (json.success) {
                        $.messager.alert('提示消息', '操作成功', 'info');
                        reload_agency_deduct_money();
                    } else {
                        $.messager.alert('提示消息', json.message, 'info');
                    }
                }, 'json');
            }
        });
    }

</script>